<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="utf-8">
    <title>后端之家</title>
    <meta name="keywords" content="后端之家">
    <meta name="description" content="后端之家">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="image/favicon.ico">
    <link rel="stylesheet" href="library/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="library/font-awesome/css/font-awesome.css" media="all">
    <link rel="stylesheet" href="admin/css/laymini.css" media="all">
    <link rel="stylesheet" href="admin/css/theme.css" media="all">
    <style id="layuimini-bg-color"></style>
</head>
<body class="layui-layout-body layuimini-all">
<div class="layui-layout layui-layout-admin">

    <div class="layui-header header">
        <div class="layui-logo layuimini-logo layuimini-back-home"></div>

        <div class="layuimini-header-content">
            <div class="layuimini-tool side-fold-click">
                <i title="展开" class="fa fa-outdent" data-side-fold="1"></i>
            </div>

            <!--电脑端头部菜单-->
            <ul class="layui-nav layui-layout-left layuimini-header-menu layuimini-menu-header-pc layuimini-pc-show"></ul>

            <!--手机端头部菜单-->
            <ul class="layui-nav layui-layout-left layuimini-header-menu layuimini-mobile-show">
                <li class="layui-nav-item">
                    <a class="side-fold-click" style="margin-right:5px">
                        <i class="fa fa-home"></i>后端之家</a>
                    <dl class="layui-nav-child layuimini-menu-header-mobile">
                    </dl>
                </li>
            </ul>

            <ul class="layui-nav layui-layout-right">
                <li class="layui-nav-item user-profile" style="display:none">
                    <a href="javascript:">
                        <span class="login-info"></span>
                    </a>
                    <dl class="layui-nav-child">
                        <dd><a href="#/page/profile.html">
                            <i class="fa fa-gear"></i> 用户设置</a>
                        </dd>
                        <dd>
                            <hr>
                        </dd>
                        <dd><a class="login-out">
                            <i class="fa fa-sign-out"></i> 退出登录</a>
                        </dd>
                    </dl>
                </li>
                <li class="layui-nav-item user-login" lay-unselect>
                    <a href="javascript:">
                        <i class="fa fa-user-circle"></i>
                        <span class="layuimini-pc-show" style="margin-left:5px">登录</span>
                    </a>
                </li>
                <li class="layui-nav-item layui-hide-xs layuimini-refresh" lay-unselect>
                    <a href="javascript:"><i class="fa fa-refresh"></i></a>
                </li>
                <li class="layui-nav-item layui-hide-xs" lay-unselect>
                    <a href="javascript:" data-check-screen="full"><i class="fa fa-arrows-alt"></i></a>
                </li>
                <li class="layui-nav-item layuimini-select-bgcolor" lay-unselect>
                    <a href="javascript:" data-bgcolor="data-bgcolor"><i class="fa fa-delicious"></i></a>
                </li>
            </ul>
        </div>
    </div>

    <!--无限极左侧菜单-->
    <div class="layui-side layui-bg-black layuimini-menu-left"></div>

    <!--手机端遮罩层-->
    <div class="layuimini-mobile-mask"></div>

    <div class="layui-body" style="line-height:0">
        <!-- 主体区域 -->
        <iframe class="layuimini-content-page" width="100%" height="100%"></iframe>
    </div>
</div>
<script src="library/jquery/jquery.js" charset="utf-8"></script>
<script src="library/layui/layui.js" charset="utf-8"></script>
<script src="library/xm-select/xm-select.js" charset="utf-8"></script>
<script src="admin/layuiMini.js" charset="utf-8"></script>
<script src="admin/common.js" charset="utf-8"></script>
<script>
    $(function () {
        miniAdmin.render({
            initUrl: "admin/home.json", // 初始化接口
            bgColorDefault: false,      // 主题默认配置
            multiModule: true,          // 是否开启多模块
            menuChildOpen: false,       // 是否默认展开菜单
            pageAnim: true,             // 切换菜单动画
        });

        $('.login-out').on("click", function () {
            $.get('../api/logout', {}, function () {
                window.location.href = "login.html";
            });
        });

        $('.user-login a').on("click", openLoginLayer);
        updateLoginInfo();
    });

    function openLoginLayer() {
        if (window.loginIndex) {
            return false
        }
        $.get("login.html", function (data) {
            window.loginIndex = layui.layer.open({
                type: 1,
                resize: false,
                area: ['60%', '80%'],
                title: false,
                closeBtn: 0,
                content: data,
                skin: 'login-layer',
                cancel: function () {
                    window.loginIndex = 0;
                }
            });
        }, 'html');
        return false;
    }

    function updateLoginInfo() {
        $.ajax({
            url: '../api/loginer',
            success: function (data) {
                $('.user-login').hide();
                var loginHtml = data.data ? '<img style="margin:5px;width:30px;height:30px;' +
                    'border-radius:15px" src="data:image;base64,' + data.data.header + '" alt=""/>' +
                    '<span class="layuimini-pc-show">' + data.data.name + '</span>' :
                    '<i class="fa fa-user-circle"></i>';
                $('.login-info').html(loginHtml);
                $('.user-profile').show();
            },
            error: function (xhr) {
                $('.user-profile').hide();
                $('.user-login').show();
                if (xhr.status === 401) {
                    openLoginLayer();
                } else {
                    layui.layer.msg("获取登录信息失败", {icon: 2});
                }
            }
        });
    }
</script>
</body>
</html>